<%-- 
    Document   : index
    Created on : Nov 8, 2013, 8:38:30 PM
    Author     : Shin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*" %>
<%@page import="model.UserBean" %>
<%@page import="database.DBClass"%>
<%@page import="validation.ValidateForm"%>
<%@ page import ="java.sql.*" %>
<%
    if (session.getAttribute("account") == null) {
        response.sendRedirect("login.jsp");
    }
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/bootstrap.min.css" rel="stylesheet"> 
        <link href="css/bootstrap-responsive.min.css" rel="stylesheet">
        <title>VIEW</title>
    </head>
    <body>
        <a href="<%=request.getContextPath()%>/insertupdate.jsp">back</a>
        <div>
            <form method="link" action="logout.jsp">
                <input type="submit" value="Logout"/>
            </form>
        </div>
        <table width="100%"border="1" class="table table-striped">
            <tr>
                <th>UserName</th>
                <th>dateOfBirth</th>
                <th>email</th>
                <th>phoneNo</th>
                    <%
                        if (session.getAttribute("account").equals("admin")) {
                    %>
                <th>action</th>
                    <%                    }
                    %>
            </tr>
            <%
                UserBean bean = new UserBean();
                DBClass dbobject = new DBClass();
                List list = dbobject.getAlldetails();
//                request.setAttribute("list", list);
//                List list2 = (List) request.getAttribute("list");
                if (list != null) {
                    for (int i = 0; i < list.size(); i++) {
                        UserBean ubean = (UserBean) list.get(i);

            %>
            <tr>
                <td><%=ubean.getUserName()%></td>
                <td><%=ubean.getDateOfBirth()%></td>
                <td><%=ubean.getEmail()%></td>
                <td><%=ubean.getPhoneNo()%></td>
                <%
                    if (session.getAttribute("account").equals("admin")) {
                %>
                <td><a href="ControllerServlet?action=edit&userName=<%=ubean.getUserName()%>">update</a>
                    |
                    <a href="ControllerServlet?action=delete&userName=<%=ubean.getUserName()%>">delete</a>
            </tr>
            <%
                        }
                    }
                }
            %>
        </table>
    </body>
</html>
